xen: Check if the range is valid in init_domheap_pages
authorJulien Grall <julien.grall@linaro.org>
Wed, 13 Nov 2013 13:37:50 +0000 (13:37 +0000)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 21 Nov 2013 10:43:01 +0000 (10:43 +0000)
On ARM, when an initrd is given to xen by U-boot, it will reserve the memory
in the device tree.
In this case, when xen decides to free unused memory, dt_unreserved_regions
will call init_domheap_pages with the start and the end of range equals. But
the latter assumes that (start > end), if not Xen will hang because the
number of pages is equals to (unsigned)-1.

Signed-off-by: Julien Grall <julien.grall@linaro.org>
Acked-by: Keir Fraser <keir@xen.org>
Acked-by: Ian Campbell <Ian.campbell@citrix.com>
CC: Jan Beulich <jbeulich@suse.com>
xen/common/page_alloc.c

index 4c17fbde40e2f88b33b6c6777ea87ff461469091..0701333fe131accfa8c17faffc1e06389302e7ec 100644 (file)
@@ -1429,6 +1429,9 @@ void init_domheap_pages(paddr_t ps, paddr_t pe)
     smfn = round_pgup(ps) >> PAGE_SHIFT;
     emfn = round_pgdown(pe) >> PAGE_SHIFT;
 
+    if ( emfn <= smfn )
+        return;
+
     init_heap_pages(mfn_to_page(smfn), emfn - smfn);
 }